/*
 * Copyright 2010 Thedwick, LLC

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

 */
package com.thedwick.jdbcGrabber.statement;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;

import com.thedwick.jdbcGrabber.sink.SQLSink;

public class gbStatement implements Statement {
	protected final Statement underlying;
	protected final SQLSink sink;
	
	public gbStatement(Statement underlying, SQLSink sink){
		this.underlying = underlying;
		this.sink = sink;
	}
	
	public Statement getUnderlying(){
		return this.underlying;
	}
	
	@Override
	public void addBatch(String sql) throws SQLException {
		this.sink.consume(sql);
		this.underlying.addBatch(sql);
	}

	@Override
	public void cancel() throws SQLException {

		this.underlying.cancel();
	}

	@Override
	public void clearBatch() throws SQLException {

		this.underlying.clearBatch();
	}

	@Override
	public void clearWarnings() throws SQLException {

		this.underlying.clearWarnings();
	}

	@Override
	public void close() throws SQLException {

		this.underlying.close();
	}

	@Override
	public boolean execute(String sql) throws SQLException {
		this.sink.consume(sql);
		return this.underlying.execute(sql);
	}

	@Override
	public boolean execute(String sql, int autoGeneratedKeys)
			throws SQLException {
		this.sink.consume(sql);
		return this.underlying.execute(sql, autoGeneratedKeys);
	}

	@Override
	public boolean execute(String sql, int[] columnIndexes) throws SQLException {
		this.sink.consume(sql);
		return this.underlying.execute(sql, columnIndexes);
	}

	@Override
	public boolean execute(String sql, String[] columnNames)
			throws SQLException {
		this.sink.consume(sql);
		return this.underlying.execute(sql, columnNames);
	}

	@Override
	public int[] executeBatch() throws SQLException {

		return this.underlying.executeBatch();
	}

	@Override
	public ResultSet executeQuery(String sql) throws SQLException {
		this.sink.consume(sql);
		return this.underlying.executeQuery(sql);
	}

	@Override
	public int executeUpdate(String sql) throws SQLException {
		this.sink.consume(sql);
		return this.underlying.executeUpdate(sql);
	}

	@Override
	public int executeUpdate(String sql, int autoGeneratedKeys)
			throws SQLException {
		this.sink.consume(sql);
		return this.underlying.executeUpdate(sql, autoGeneratedKeys);
	}

	@Override
	public int executeUpdate(String sql, int[] columnIndexes)
			throws SQLException {
		this.sink.consume(sql);
		return this.underlying.executeUpdate(sql, columnIndexes);
	}

	@Override
	public int executeUpdate(String sql, String[] columnNames)
			throws SQLException {
		this.sink.consume(sql);
		return this.underlying.executeUpdate(sql, columnNames);
	}

	@Override
	public Connection getConnection() throws SQLException {

		return this.underlying.getConnection();
	}

	@Override
	public int getFetchDirection() throws SQLException {

		return this.underlying.getFetchDirection();
	}

	@Override
	public int getFetchSize() throws SQLException {

		return this.underlying.getFetchSize();
	}

	@Override
	public ResultSet getGeneratedKeys() throws SQLException {

		return this.underlying.getGeneratedKeys();
	}

	@Override
	public int getMaxFieldSize() throws SQLException {

		return this.underlying.getMaxFieldSize();
	}

	@Override
	public int getMaxRows() throws SQLException {

		return this.underlying.getMaxRows();
	}

	@Override
	public boolean getMoreResults() throws SQLException {

		return this.underlying.getMoreResults();
	}

	@Override
	public boolean getMoreResults(int current) throws SQLException {

		return this.underlying.getMoreResults(current);
	}

	@Override
	public int getQueryTimeout() throws SQLException {

		return this.underlying.getQueryTimeout();
	}

	@Override
	public ResultSet getResultSet() throws SQLException {

		return this.underlying.getResultSet();
	}

	@Override
	public int getResultSetConcurrency() throws SQLException {

		return this.underlying.getResultSetConcurrency();
	}

	@Override
	public int getResultSetHoldability() throws SQLException {

		return this.underlying.getResultSetHoldability();
	}

	@Override
	public int getResultSetType() throws SQLException {

		return this.underlying.getResultSetType();
	}

	@Override
	public int getUpdateCount() throws SQLException {

		return this.underlying.getUpdateCount();
	}

	@Override
	public SQLWarning getWarnings() throws SQLException {

		return this.underlying.getWarnings();
	}

	@Override
	public boolean isClosed() throws SQLException {

		return this.underlying.isClosed();
	}

	@Override
	public boolean isPoolable() throws SQLException {

		return this.underlying.isPoolable();
	}

	@Override
	public void setCursorName(String name) throws SQLException {

		this.underlying.setCursorName(name);
	}

	@Override
	public void setEscapeProcessing(boolean enable) throws SQLException {

		this.underlying.setEscapeProcessing(enable);
	}

	@Override
	public void setFetchDirection(int direction) throws SQLException {

		this.underlying.setFetchDirection(direction);
	}

	@Override
	public void setFetchSize(int rows) throws SQLException {

		this.underlying.setFetchSize(rows);
	}

	@Override
	public void setMaxFieldSize(int max) throws SQLException {

		this.underlying.setMaxFieldSize(max);
	}

	@Override
	public void setMaxRows(int max) throws SQLException {

		this.underlying.setMaxRows(max);
	}

	@Override
	public void setPoolable(boolean poolable) throws SQLException {

		this.underlying.setPoolable(poolable);
	}

	@Override
	public void setQueryTimeout(int seconds) throws SQLException {

		this.underlying.setQueryTimeout(seconds);
	}

	@Override
	public boolean isWrapperFor(Class<?> iface) throws SQLException {

		return this.underlying.isWrapperFor(iface);
	}

	@Override
	public <T> T unwrap(Class<T> iface) throws SQLException {

		return this.underlying.unwrap(iface);
	}

}
